package com.jd.platform.async.demo;

import java.util.Date;
import java.util.Map;

import com.jd.platform.async.callback.ICallback;
import com.jd.platform.async.callback.IWorker;
import com.jd.platform.async.worker.WorkResult;
import com.jd.platform.async.wrapper.WorkerWrapper;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;

public class WorkerC implements IWorker<Integer, Integer>, ICallback<Integer, Integer> {
	
	@Override
	public void begin() {
		System.out.println("C线程：" + Thread.currentThread().getName() + "开始执行了，" + DateUtil.format(new Date(System.currentTimeMillis()), "yyyy-MM-dd HH:mm:ss"));
	}

	@Override
	public void result(boolean success, Integer param, WorkResult<Integer> workResult) {
		System.out.println("C参数：" + JSONUtil.toJsonStr(param));
		System.out.println("C结果：" + JSONUtil.toJsonStr(workResult));
		System.out.println("C线程：" + Thread.currentThread().getName() + "结束时间" + DateUtil.format(new Date(System.currentTimeMillis()), "yyyy-MM-dd HH:mm:ss"));
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Integer action(Integer object, Map<String, WorkerWrapper> allWrappers) {
		return object + 2;
	}
	
	@Override
	public Integer defaultValue() {
		System.out.println("C默认值");
		return 102;
	}

}
